package com.ruoyi.system.service.impl;

import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.FltVehicleVideo;
import com.ruoyi.system.mapper.FltVehicleVideoMapper;
import com.ruoyi.system.service.IFltVehicleVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 检测视频数据Service业务层处理
 *
 * @author fulu
 * @date 2023-09-15
 */
@Service
public class FltVehicleVideoServiceImpl implements IFltVehicleVideoService {
    @Autowired
    private FltVehicleVideoMapper fltVehicleVideoMapper;

    @Override
    public FltVehicleVideo getByCheckNo(String checkNo) {
        String tableName = "flt_vehicle_video_" + StrUtil.subPre(checkNo, 6);
        return fltVehicleVideoMapper.getByCheckNo(tableName, checkNo);
    }

    @Override
    public FltVehicleVideo selectFltVehicleVideoById(Long id) {
        return fltVehicleVideoMapper.selectFltVehicleVideoById(id);
    }

    @Override
    public List<FltVehicleVideo> selectFltVehicleVideoList(FltVehicleVideo fltVehicleVideo) {
        return fltVehicleVideoMapper.selectFltVehicleVideoList(fltVehicleVideo);
    }

    @Override
    public int insertFltVehicleVideo(FltVehicleVideo fltVehicleVideo) {
        fltVehicleVideo.setTableName("flt_vehicle_video_" + DateUtils.parseDateToStr("yyyyMM", fltVehicleVideo.getCheckTime()));
        return fltVehicleVideoMapper.insertFltVehicleVideo(fltVehicleVideo);
    }

    @Override
    public int updateFltVehicleVideo(FltVehicleVideo fltVehicleVideo) {
        fltVehicleVideo.setUpdateTime(DateUtils.getNowDate());
        return fltVehicleVideoMapper.updateFltVehicleVideo(fltVehicleVideo);
    }

}
